package com.itetchologyandenglish.home.controller.Api;

import com.itetchologyandenglish.home.config.Log;
import com.itetchologyandenglish.home.enetity.Assistant;
import com.itetchologyandenglish.home.enetity.Result;
import com.itetchologyandenglish.home.service.AssistantService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
@Api(tags={"外贸助手模块"})
@RestController
@RequestMapping("/assistant")
public class AssistantApiController {
    @Resource
    AssistantService assistantService;
    @ApiOperation("查看外贸列表")
    @Log("外贸助手-外贸列表")
    @RequestMapping(value="/assistantlist",produces = "application/json")
    public Result<List<Assistant>> assistantlist(){
        System.out.println(assistantService.getAssistantAll());
        return new Result<List<Assistant>>(200,"success",assistantService.getAssistantAll());
    }
    @ApiOperation("添加外贸信息")
    @Log("外贸助手-添加外贸")
    @RequestMapping(value="/addassitant",produces = "application/json")
    public Result addassitant(String address,String aname) {
       if(assistantService.addassitant(address,aname)){
           return new Result(200,"添加成功");
       }else{
           return new Result(404,"添加失败");
       }
    }
    @ApiOperation("更新外贸")
    @Log("外贸助手-更新外贸")
    @RequestMapping(value="/updateassistant",produces = "application/json")
    public Result updateassistant(String address ,String aname ,Integer id){
        if(assistantService.updateassistant(address,aname,id)){
            return new Result(200,"更新成功");
        }else{
            return new Result(404,"更新失败");
        }
    }

}
